<?php

ini_set("memory_limit", "100M");
ini_set("max_execution_time", 36000);

require_once('../../config/maptrick.conf.php');
require_once(SITE_ROOT . 'class/bean/Country.class.php');
require_once(SITE_ROOT . 'class/bean/League.class.php');
require_once(SITE_ROOT . 'class/bean/Team.class.php');
require_once(SITE_ROOT . 'class/db/DBCountry.class.php');
require_once(SITE_ROOT . 'class/db/DBLeague.class.php');

try {
	if ($_GET["pass"] != SCRIPT_PWD) die("Incorrect password");

	$dbcountry = new DBCountry();
	$dbleague = new DBLeague();
	
	$countries = $dbcountry->getCountries();	
	
	foreach ($countries as $country) {
		echo $country->getEnglishName() . "\n";
		$leagues = $dbleague->getLeaguesByCountry($country);
		$oldID = 0;
		foreach ($leagues as $league) {
			if (($league->getLeagueID() - $oldID) > 1) {
				if ($oldID !== 0) echo $oldID . "\n";
				echo $league->getLeagueID() . ",";
			}
			$oldID = $league->getLeagueID();	
		}
	echo $oldID . "\n";
	echo "\n";
	}
}
catch (Exception $e) {
	echo $e->getMessage();
}

?>